# -*- coding=utf-8 -*-
from unittestreport import TestRunner
from common.mylog import log
from conf.constant import cons
import os
import sys
import unittest


def all_case():
    log.info('*******启动测试运行程序*******')
    # 一：创建测试套件
    testunit = unittest.TestSuite()

    # 二：加载测试用例到测试套件中
    loader = unittest.TestLoader()
    testunit.addTest(loader.discover(cons.CASE_PATH))

    filename = os.path.join(cons.HTML_REPORT_PATH, cons.date_file1 + '.html')
    sys.path.append(filename)

    # 三：执行测试套件，生成测试报告
    runner = TestRunner(testunit,
                        filename=filename,
                        report_dir=cons.HTML_REPORT_PATH,
                        title='测试报告',
                        tester='阿离',
                        desc="接口自动化测试报告",
                        templates=1
                        )
    runner.run()
    log.info('*******测试用例执行结束*******')

all_case()


